var a = require("../../../../@babel/runtime/helpers/toConsumableArray"), t = getApp();

Page({
    data: {
        language: "",
        datas: [],
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(a) {
        this._getData();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    _getData: function() {
        var a = this, e = t.getNetAddresss("plugin.commission.api.commission.get-commission-list");
        e += "&commission_type=3", t._getNetWork({
            url: e,
            data: {
                page: a.data.page
            },
            success: function(t) {
                var e = t.data;
                1 == e.result && (a.setData({
                    datas: e.data.data,
                    total_page: e.data.last_page,
                    isLoadMore: !0,
                    page: e.data.current_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                }));
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    getMoreData: function() {
        var e = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var o = this.data.page;
            o += 1, this.setData({
                page: o
            });
            var s = t.getNetAddresss("plugin.commission.api.commission.get-commission-list");
            s += "&commission_type=3", t._getNetWork({
                url: s,
                data: {
                    page: e.data.page
                },
                success: function(t) {
                    var o = t.data;
                    if (1 == o.result) {
                        var s = o.data.data, n = [].concat(a(e.data.datas), a(s));
                        e.setData({
                            datas: n,
                            total_page: o.data.last_page,
                            isLoadMore: !0
                        });
                    }
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        }
    }
});